﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARUserControls
{
	/// <summary>
	/// SARViewSwitch.xaml 的交互逻辑
	/// </summary>
	public partial class SARViewSwitch : UserControl
	{
		public SARViewSwitch()
		{
			this.InitializeComponent();
		}

        /// <summary>
        /// 切换事件，参数为bool，true表示切换到左边，false表示切换到右边。
        /// </summary>
        public event SwitchHandler SARButtonSwitched;

        private bool currentIsLeft = true;
        private void gridLeftMouse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (currentIsLeft)
            {
                return;
            }
            currentIsLeft = true;
            pathLeftMask.Opacity = 1;
            pathRightMask.Opacity = 0;
            if (SARButtonSwitched != null)
            {
                SARButtonSwitched.Invoke(true);
            }
        }

        private void gridRightMouse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!currentIsLeft)
            {
                return;
            }
            currentIsLeft = false;
            pathLeftMask.Opacity = 0;
            pathRightMask.Opacity = 1;
            if (SARButtonSwitched != null)
            {
                SARButtonSwitched.Invoke(false);
            }
        }
	}

    public delegate void SwitchHandler(bool isLeft);
}